package behavioral.memento.blackbox;

public class Main {

    public static void main(String[] args) {
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();
        originator.setState("running");
        System.out.println(originator.getState());
        IMemento memento = originator.createMemento();
        caretaker.saveMemento(memento);
        //memento.  这里没办法对备忘录对象做任何操作，保证了安全性
        originator.setState("stoping");
        System.out.println(originator.getState());
        originator.restoreMemento(caretaker.retrieveMemento());
        System.out.println(originator.getState());
    }
}
